<?php
 define('IN_DAEM', true); include '../includes/init.php'; $startDate = date('Y-m-01'); $endDate = date('Y-m-t'); $endDateTime = strtotime($startDate); $title = '最近12个月的各个月的课程结算情况'; $sql = "select DATE_FORMAT(min(course_date),'%Y-%m') as minDate,DATE_FORMAT(max(course_date),'%Y-%m') as maxDate 
		from ".DB_DAEMDB.".".TB_SUFFIX."hr_student_course_record where unix_timestamp(course_date)<='".strtotime($endDate)."'"; $result = $db->query_first($sql); $chartMinDate = $result['minDate']; $chartMaxDate = $result['maxDate']; $temStartDateTime = mktime(0,0,0,date('n',$endDateTime)-11,1,date('Y',$endDateTime)); $temStartDate = date('Y-m',$temStartDateTime); if ($temStartDateTime>strtotime($chartMinDate)) { $chartMinDate = date('Y-m',$temStartDateTime); } if (strtotime($chartMinDate) < strtotime(date('Y-m',strtotime(DAEM_START_DATE)))) { $chartMinDate = date('Y-m',strtotime(DAEM_START_DATE)); } $chartDateAry = array(); for ($i=0;$i<=11;$i++) { $temChartTime = mktime(0,0,0,date('n',strtotime($chartMinDate))+$i,1,date('Y',strtotime($chartMinDate))); if ($temChartTime>strtotime($chartMaxDate)) break; else { $chartDateAry[] = date('Y-m',$temChartTime); } } $chartMonthIOAry = array(); $sql = "select DATE_FORMAT(course_date,'%Y-%m') as monthDate,sum(endTime-startTime) as totalCourseTime  
		from ".DB_DAEMDB.".".TB_SUFFIX."hr_student_course_record  
		where application_status = '2' and absence = '2' 
		group by monthDate order by course_date"; $query = $db->query($sql); $dataAry = array(); while ($row = $db->fetch_array($query)) { $dataAry[] = $row; } foreach ($dataAry as $val) { echo $val['monthDate']."已审批课时合计 ：".$val['totalCourseTime']." 分钟，折合共 ：".$totalDurationConvert." 小时</br>"; } 